﻿using NUnit.Framework;
using System;

namespace com.ptrampert.LibVLCBind.Tests
{
    [TestFixture]
    public class TestVLCInstance
    {
        private IVLCFactory factory;
        private IVLCInstance vlc;

        [TestFixtureSetUp]
        public void Setup()
        {
            factory = new TwoflowerVLCFactory();
            vlc = factory.InitializeVLC();
        }

        [Test]
        public void TestGetMedia()
        {
            using (IMedia media = vlc.GetVLCMedia("Robot Chicken - Atta Toy.avi", true))
            {
                Assert.IsNotNull(media);
            }
        }

        [Test]
        public void TestGetMediaPlayer()
        {
            using (IMediaPlayer player = vlc.CreateMediaPlayer())
            {
                Assert.IsNotNull(player);
            }
        }

        [Test]
        public void TestCreatePlayerFromMedia()
        {
            using (IMedia media = vlc.GetVLCMedia("Robot Chicken - Atta Toy.avi", true))
            {
                using (IMediaPlayer player = vlc.CreateMediaPlayer<IVideoPlayer>(media))
                {
                    Assert.IsNotNull(player);
                }
            }
        }

        [Test]
        public void TestAudioOutput()
        {
            foreach (AudioOutput ao in vlc.AudioOutputs)
            {
                Assert.IsNotNull(ao.Name);
                Assert.IsNotNull(ao.Description);
            }
        }

        [Test]
        public void TestFactoryProperties()
        {
            Assert.AreEqual("2.0.7 Twoflower", factory.LibVLCVersion);
            Assert.AreEqual("gcc version 4.6.3 (GCC) ", factory.LibVLCCompiler);
            Assert.AreEqual("2.0.7-7-gf12ab4a", factory.LibVLCChangeset);
        }

        [TestFixtureTearDown]
        public void Cleanup()
        {
            vlc.Dispose();
        }
    }
}
